import Vue from "vue";
import VueRouter from "vue-router";
// TODO. 待优化
// import Home from "../views/Home.vue";

// import Layout from "@/layout/Index.vue";

Vue.use(VueRouter);

// const originalPush = VueRouter.prototype.push;
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch((err) => err);
// };

const routes = [
  {
    path: "/",
    name: "Layout",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../layout/Index.vue"),
    children: [
      {
        path: "programManagement",
        name: "Layout",
        alias: "/",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        meta: { name1: "共创空间", name2: "栏目管理" },
        component: () =>
          import(/* webpackChunkName: "about" */ "../views/programManagement.vue"),
      },
      {
        path: "contentManagement",
        name: "Layout",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        meta: { name1: "共创空间", name2: "内容管理" },
        component: () =>
          import(/* webpackChunkName: "about" */ "../views/contentManagement/contentManagement.vue"),
      },
    ],
  },

  // {
  //   path: "/",
  //   name: "Home",
  //   component: Home,
  // },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
